package com.xinhua.erp.repo;

import com.xinhua.erp.pojo.ProcessCompound;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface ProcessCompoundRepo extends JpaRepository<ProcessCompound,Long>, JpaSpecificationExecutor<ProcessCompound> {

    Page<ProcessCompound> findAllByType(String type, Pageable pageable);

    Page<ProcessCompound> findAllByTypeAndState(String type,String state,Pageable pageable);

    @Modifying
    @Query(value = "update process_compound set state='已审核' where id =?",nativeQuery = true)
    void updateState(Long id);
}
